package com.tungse.study.io.three;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server3 {

    public static void main(String[] args) {
        try {
            System.out.println("服务端启动");
            //1 定义一个serverSocket对象进行服务端的端口注册
            ServerSocket serverSocket = new ServerSocket(9999);
            while (true) {
                //2 监听客户端的socket链接请求
                Socket socket = serverSocket.accept();
                new MsgReadThread(socket).start();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
}
